package com.example.gulimall.common.exceptions;

import com.example.gulimall.common.enums.ServiceCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>DESC: </p>
 * <p>DATE: 2019/2/13</p>
 * <p>VERSION:1.0.0</p>
 * <p>@AUTHOR: JGD</p>
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ApiException extends RuntimeException {
    private static final long serialVersionUID = -3005819231762830260L;

    public ApiException(ServiceCodeEnum codeEnum) {
        super(codeEnum.getMessage());
        this.errorCode = codeEnum.getCode();
    }

    public ApiException(Integer code, String message) {
        super(message);
        this.errorCode = code;
        this.data = null;
    }

    public ApiException(Integer code, String message, Object data) {
        super(message);
        this.errorCode = code;
        this.data = data;
    }

    private Integer errorCode;

    private Object data;
}
